package com.j283_5.wisdom_park.vo.device_management;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.j283_5.wisdom_park.pojo.DeviceInformation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * @author wsir
 * @create 2022-04-30-14:51
 */
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class DeviceInformationVo implements Serializable {
    /**
     * 设备信息id
     */
    @TableId(value = "dinf_id", type = IdType.AUTO)
    private Integer dinfId;

    /**
     * 设备名称
     */
    private String ddetName;

    /**
     * 设备编号
     */
    private String ddetNumber;

    /**
     * 设备型号
     */
    private String ddetType;

    /**
     * 安装位置
     */
    private String dinfLocation;

    /**
     * 0:正常，1：为禁用2：异常
     */
    private String dinfState;

    /**
     * 运行时常
     */
    private Integer dinfRuntime;

    /**
     * 设备最近更新时间
     */
    private Timestamp dinfUpdate;

    /**
     * 设备类型名称
     */
    private String ddetStyle;

    public DeviceInformationVo(DeviceInformation deviceInformation){
        this.dinfId = deviceInformation.getDinfId();
        this.ddetName = deviceInformation.getDdetName();
        this.ddetNumber = deviceInformation.getDdetNumber();
        this.ddetType = deviceInformation.getDdetType();
        this.dinfLocation = deviceInformation.getDinfLocation();
        if (deviceInformation.getDinfState() != null) {
            setDinfState(deviceInformation.getDinfState());
        }
        this.dinfRuntime = deviceInformation.getDinfRuntime();
        this.dinfUpdate = deviceInformation.getDinfUpdate();
        this.ddetStyle = deviceInformation.getDdetStyle();
    }

    public Integer getDinfId() {
        return dinfId;
    }

    public void setDinfId(Integer dinfId) {
        this.dinfId = dinfId;
    }

    public String getDdetName() {
        return ddetName;
    }

    public void setDdetName(String ddetName) {
        this.ddetName = ddetName;
    }

    public String getDdetNumber() {
        return ddetNumber;
    }

    public void setDdetNumber(String ddetNumber) {
        this.ddetNumber = ddetNumber;
    }

    public String getDdetType() {
        return ddetType;
    }

    public void setDdetType(String ddetType) {
        this.ddetType = ddetType;
    }

    public String getDinfLocation() {
        return dinfLocation;
    }

    public void setDinfLocation(String dinfLocation) {
        this.dinfLocation = dinfLocation;
    }

    public String getDinfState() {
        return dinfState;
    }

    public void setDinfState(String dinfState) {
        this.dinfState = dinfState;
    }

    public Integer getDinfRuntime() {
        return dinfRuntime;
    }

    public void setDinfRuntime(Integer dinfRuntime) {
        this.dinfRuntime = dinfRuntime;
    }

    public Timestamp getDinfUpdate() {
        return dinfUpdate;
    }

    public void setDinfUpdate(Timestamp dinfUpdate) {
        this.dinfUpdate = dinfUpdate;
    }

    public String getDdetStyle() {
        return ddetStyle;
    }

    public void setDdetStyle(String ddetStyle) {
        this.ddetStyle = ddetStyle;
    }



    public void setDinfState(Integer dinfState){
        switch (dinfState){
            case 0:
                this.dinfState = "正常";
                return;
            case 1:
                this.dinfState = "禁用";
                return;
            case 2:
                this.dinfState = "异常";
                return;
        }
    }
}
